display: Add new virtual gdk_display_get_startup_notification_id() method.
authorMario Sanchez Prada <msanchez@gnome.org>
Mon, 4 Jun 2018 16:27:36 +0000 (17:27 +0100)
committerMario Sanchez Prada <msanchez@gnome.org>
Mon, 11 Jun 2018 15:28:24 +0000 (16:28 +0100)
Includes implementation for Wayland and X11, which are the only backends
implementing the Startup Notification Protocol, returns NULL otherwise.

https://gitlab.gnome.org/GNOME/gtk/issues/1084

gdk/gdkdisplay.c
gdk/gdkdisplay.h
gdk/gdkdisplayprivate.h
gdk/wayland/gdkdisplay-wayland.c
gdk/wayland/gdkwaylanddisplay.h
gdk/x11/gdkdisplay-x11.c

index 93449e99be15a04a9758dac3b24fcc9e0d3bffdd..eadc3c7ccbada8a8b0d52a74d303f72423a4cf54 100644 (file)
@@ -1283,6 +1283,28 @@ gdk_display_notify_startup_complete (GdkDisplay  *display,
   GDK_DISPLAY_GET_CLASS (display)->notify_startup_complete (display, startup_id);
 }
 
+/**
+ * gdk_display_get_startup_notification_id:
+ * @display: (type GdkX11Display): a #GdkDisplay
+ *
+ * Gets the startup notification ID for a Wayland display, or %NULL
+ * if no ID has been defined.
+ *
+ * Returns: the startup notification ID for @display, or %NULL
+ *
+ * Since: 4.0
+ */
+const gchar *
+gdk_display_get_startup_notification_id (GdkDisplay *display)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  if (GDK_DISPLAY_GET_CLASS (display)->get_startup_notification_id == NULL)
+    return NULL;
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_startup_notification_id (display);
+}
+
 void
 _gdk_display_pause_events (GdkDisplay *display)
 {
index b9f5d71fd8e2eeaf99c7444308229d2756d85ce9..547e2a10de645cf3cb0c2081309f751830d7e594 100644 (file)
@@ -94,6 +94,8 @@ gboolean gdk_display_supports_input_shapes     (GdkDisplay    *display);
 GDK_AVAILABLE_IN_ALL
 void     gdk_display_notify_startup_complete   (GdkDisplay    *display,
                                                 const gchar   *startup_id);
+GDK_AVAILABLE_IN_ALL
+const gchar * gdk_display_get_startup_notification_id (GdkDisplay *display);
 
 GDK_AVAILABLE_IN_ALL
 GdkAppLaunchContext *gdk_display_get_app_launch_context (GdkDisplay *display);
index ac873281b5244957f791235e42bc6756115474e2..28a656c9d8976bffbb37b37aabc7fd49481b9db3 100644 (file)
@@ -136,6 +136,8 @@ struct _GdkDisplayClass
 
   void                       (*notify_startup_complete) (GdkDisplay  *display,
                                                          const gchar *startup_id);
+  const gchar *              (*get_startup_notification_id) (GdkDisplay  *display);
+
   void                       (*event_data_copy) (GdkDisplay     *display,
                                                  const GdkEvent *event,
                                                  GdkEvent       *new_event);
index 2f46817be4835631245e16a21cd4a52abbe413ab..4c264fabee69faa9026f2e1a1b3018fac348f07f 100644 (file)
@@ -857,6 +857,23 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display)
   return ++serial;
 }
 
+/**
+ * gdk_wayland_display_get_startup_notification_id:
+ * @display: (type GdkX11Display): a #GdkDisplay
+ *
+ * Gets the startup notification ID for a Wayland display, or %NULL
+ * if no ID has been defined.
+ *
+ * Returns: the startup notification ID for @display, or %NULL
+ *
+ * Since: 4.0
+ */
+const gchar *
+gdk_wayland_display_get_startup_notification_id (GdkDisplay  *display)
+{
+  return GDK_WAYLAND_DISPLAY (display)->startup_notification_id;
+}
+
 /**
  * gdk_wayland_display_set_startup_notification_id:
  * @display: (type GdkWaylandDisplay): a #GdkDisplay
@@ -1005,6 +1022,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
   display_class->supports_input_shapes = gdk_wayland_display_supports_input_shapes;
   display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
   display_class->get_next_serial = gdk_wayland_display_get_next_serial;
+  display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id;
   display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
   display_class->create_surface_impl = _gdk_wayland_display_create_surface_impl;
   display_class->get_keymap = _gdk_wayland_display_get_keymap;
index 64c2b55f453ccae2935819fd3921e59078dc481a..c6f3b24747ffdc9c2a9580aa714257ba8c220206 100644 (file)
@@ -54,6 +54,8 @@ void                    gdk_wayland_display_set_cursor_theme    (GdkDisplay  *di
                                                                  const gchar *theme,
                                                                  gint         size);
 GDK_AVAILABLE_IN_ALL
+const gchar *           gdk_wayland_display_get_startup_notification_id (GdkDisplay *display);
+GDK_AVAILABLE_IN_ALL
 void                    gdk_wayland_display_set_startup_notification_id (GdkDisplay *display,
                                                                          const char *startup_id);
 
index eaa457dcd7c1efe4abd338b5c0341f17633210b6..735b6e06c1dc4136a2f5e03665392ec57fc2aac1 100644 (file)
@@ -3042,6 +3042,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
   display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
 
   display_class->get_next_serial = gdk_x11_display_get_next_serial;
+  display_class->get_startup_notification_id = gdk_x11_display_get_startup_notification_id;
   display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
   display_class->create_surface_impl = _gdk_x11_display_create_surface_impl;
   display_class->get_keymap = gdk_x11_display_get_keymap;